<!DOCTYPE html>
<html>
<head>
<title></title>
<#include "/header.html" />
</head>
<body>
<link type="text/css" rel="stylesheet" href="${request.contextPath}/statics/plugins/components/fileinput/css/fileinput.css" />
<script type="text/javascript" src="${request.contextPath}/statics/plugins/components/fileinput/js/fileinput.js"></script>
<script type="text/javascript" src="${request.contextPath}/statics/plugins/components/fileinput/js/zh.js"></script>
<div id="rrapp" v-cloak>
	<div v-show="showList">
		<div class="grid-btn">
            <div class="form-group col-sm-2">
                <input type="text" class="form-control" v-model="q.apkCode" @keyup.enter="query" placeholder="apk版本号">
            </div>
            <a class="btn btn-default" @click="query">查询</a>
			<#if shiro.hasPermission("sysappversion:save")>
            <a class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
			</#if>
			<#if shiro.hasPermission("sysappversion:update")>
            <a class="btn btn-modify" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
			</#if>
			<#if shiro.hasPermission("sysappversion:delete")>
            <a class="btn btn-delete" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
			</#if>
		</div>
	    <table id="jqGrid"></table>
	    <div id="jqGridPager"></div>
    </div>
    
    <div v-show="!showList" class="panel panel-default">
		<div class="panel-heading">{{title}}</div>
		<form class="form-horizontal">
					<div class="form-group">
			   	<div class="col-sm-2 control-label">apk版本</div>
			   	<div class="col-sm-10">
			      <input type="text" class="form-control" v-model="sysAppversion.apkCode" placeholder="apk版本"/>
			    </div>
			</div>
					<div class="form-group">
			   	<div class="col-sm-2 control-label">app版本号</div>
			   	<div class="col-sm-10">
			      <input type="text" class="form-control" v-model="sysAppversion.versionCode" placeholder="app版本号"/>
			    </div>
			</div>
					<div class="form-group">
			   	<div class="col-sm-2 control-label">app版本名称</div>
			   	<div class="col-sm-10">
			      <input type="text" class="form-control" v-model="sysAppversion.versionName" placeholder="app版本名称"/>
			    </div>
			</div>
			<div class="form-group">
			   	<div class="col-sm-2 control-label">上传APK文件</div>
			   	<div class="col-sm-10">
					<input id="file" class="file file-loading" type="file" name="file" >
					<input type="hidden" class="form-control" v-model="sysAppversion.apkPath" placeholder="apk路径" id="apkPath"/>
					<input type="text" class="form-control"  placeholder="" id="fileName" readonly="readonly" placeholder="文件名称" v-model="sysEnclosureEntity.fileName"/>
			    </div>
			</div>
					<div class="form-group">
			   	<div class="col-sm-2 control-label">app版本信息</div>
			   	<div class="col-sm-10">
					<textarea v-model="sysAppversion.versionMessage" placeholder="app版本信息" class="form-control" cols="20" ></textarea>
			    </div>
			</div>
					<div class="form-group">
				<div class="col-sm-2 control-label"></div> 
				<input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
				&nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回"/>
			</div>
		</form>
	</div>
</div>

<script src="${request.contextPath}/statics/js/modules/sys/sysappversion.js?_${.now?long}"></script>
<script>
    $("#file").fileinput({
        language: 'zh', //设置语言
        uploadUrl: "${request.contextPath}/sysenclosure/uploadFile", //上传的地址
        allowedFileExtensions: ['apk'],//接收的文件后缀
        //uploadExtraData:{"id": 1, "fileName":'123.mp3'},
        uploadAsync: true, //默认异步上传
        showUpload: true, //是否显示上传按钮
        showRemove : true, //显示移除按钮
        showPreview : false, //是否显示预览
        showCaption: true,//是否显示标题
        browseClass: "btn btn-primary", //按钮样式
        dropZoneEnabled: false,//是否显示拖拽区域
        //minImageWidth: 50, //图片的最小宽度
        //minImageHeight: 50,//图片的最小高度
        //maxImageWidth: 1000,//图片的最大宽度
        //maxImageHeight: 1000,//图片的最大高度
        //maxFileSize: 0,//单位为kb，如果为0表示不限制文件大小
        //minFileCount: 0,
        maxFileCount: 1, //表示允许同时上传的最大文件个数
        enctype: 'multipart/form-data',
        validateInitialCount:true,
        previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
        msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}！"
    });
    $("#file").on("fileuploaded", function (event, data, previewId, index) {
        if(data.response.code==0){
            alert('上传成功');
            var id=data.response.sysEnclosureEntity.id;
            var name=data.response.sysEnclosureEntity.fileName;
            vm.sysAppversion.apkPath=id;
            $("#apkPath").val(id);
            $("#fileName").val(name);
		}else{
            alert("上传失败");
		}
    });
    $('#file').on('fileerror', function(event, data, msg) {
        alert("上传失败");
    });
    $("#file").on("filebatchselected", function(event, files) {
        if(files.length==0){
             alert('只能上传.apk文件');
             return;
		}
    });
</script>
</body>
</html>